#
# Deploy to the deeptalk web server.
#

[CmdletBinding()]
param (
  [Parameter(mandatory=$true)]
  [string] $release,
  [Parameter(mandatory=$true)]
  [string] $computer,
  [Parameter(mandatory=$true)]
  [string] $username,
  [Parameter(mandatory=$true)]
  [string] $password
  )

if ($release -ne "Release") {
  Write-Host "WARNING: sending results of a $release build to the server, which isn't 'Release'!"
}

$location = [System.IO.DirectoryInfo] "$PWD\..\Builder\bin\$release"
$locationFN = $location.FullName
if (-not $location.Exists) {
    Write-Host "ERROR: Unable to find the source files to sync with the server at $locationFN"
    return
}


set-alias msdeploy "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe"

$computerInfo = "computerName=$computer,username=$username,password=$password"

#
# That is all the checks we need to do. Now we can actually send it up!
#

msdeploy -verb:sync `
	-source:contentPath="$locationFN" `
	-dest:contentPath="c:\users\gwatts\Documents\PivotWeb\Builder,$computerInfo" `
	-preSync:runCommand=C:\Users\gwatts\Documents\PivotWeb\stopBuilder.cmd `
	-postSync:runCommand=C:\Users\gwatts\Documents\PivotWeb\startBuilder.cmd

#msdeploy -verb:sync -source:runCommand=C:\Users\gwatts\Documents\nugetPackages\stopBuilder.cmd -dest:"auto,computerName=deeptalk.phys.washington.edu,username=gwatts,password=XXX"

#msdeploy -verb:sync -source:contentPath="$locationFN" -dest:contentPath="c:\users\gwatts\Documents\nugetPackages\Builder,$computerInfo" -whatif

#msdeploy -verb:sync -source:runCommand=C:\Users\gwatts\Documents\nugetPackages\startBuilder.cmd -dest:"auto,computerName=deeptalk.phys.washington.edu,username=gwatts,password=XX"
